<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="../framework/header.jsp" />
 <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/assemblyLine.css" />
<style type="text/css">

</style>
<div id="container"
	class="effect aside-float aside-bright mainnav-lg navbar-fixed mainnav-fixed aside-fixed">

	<jsp:include page="../framework/topper.jsp" />
	<div class="boxed">
		<!--=======================  页面主体内容  ============================-->
		<div id="content-container">
			<!-- ============================  页面内容区  ================================== -->
			<div  id="page-content">
					<div class="row">
							<div class="col-md-8">
									<div class="panel panel-default">
											<div class="panel-heading">
												<h3 class="panel-title">
													流水线
												</h3>
											</div>
											<div class="panel-body"  id="" style="height:575px;overflow-y:scroll;overflow-x:hidden; ">
													<div class="col-lg-12">
													<div class="pad-top pad-btm bg-light">
														<div class="timeline pipeline">
															<div id="one" class="timeline-header">
																<div class="timeline-stat">
																	<div class="timeline-icon">
																		<i class="fa fa-file-text icon-2x text-success"></i>
																	</div>
																</div>
																<div class="timeline-label">
																	<div class="panel">
																		<div class="panel-heading">
																			<div class="panel-control">
																				<a class="btn btn-link btn-lg" >
															                        <i class="fa fa-pencil"></i> 
															                    </a>
																			</div>
																			<h3 class="panel-title">基本信息</h3>
																		</div>
																		<div class="panel-body">
																			<div class="row pad-btm pad-top">
																				<label class="col-sm-2 text-right">流水线名称:</label>
																				<div class="col-sm-8">
																					<label class="line-name"></label>
																				</div>
																			</div>
																			<div class="row pad-btm">
																				<label class="col-sm-2 text-right">描述:</label>
																				<div class="col-sm-8">
																					<span class="line-desc"></span>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
															</div>
															
															<div class="timeline-entry timeline-add">
																<div class="timeline-stat">
																	<div class="timeline-icon">
																		<i class="fa fa-plus-square-o icon-2x"></i>
																	</div>
																</div>
																<div class="timeline-label">
																	<button class="btn btn-block"><i class="fa fa-plus"></i> 阶段</button>
																</div>
															</div>
															<div  id="two" class="timeline-wrap ui-state-default">
																<div class="timeline-entry timeline-source">
																	<div class="timeline-stat">
																		<div class="timeline-icon">
																			<i class="fa fa-file-code-o icon-2x"></i>
																		</div>
																	</div>
																	<div class="timeline-label">
																		<div class="panel">
																			<div class="panel-heading timeline-sort-drag">
																				<div class="panel-control">
																					<a class="btn btn-link btn-lg" >
																                        <i class="fa fa-pencil"></i> 
																                    </a>
																					<a class="btn btn-link btn-lg" >
																                        <i class="fa fa-trash"></i> 
																                    </a>
																				</div>
																				<h3 class="panel-title stage-name">Source</h3>
																			</div>
																			<div class="panel-body plan-item-list connectedSortable">
																				<div class="plan-item-wrap">
																					<a class="plan-item-add plan-wrap-add">
																						<i class="cds-icon-add"></i> 
																						<span>任务</span>
																					</a>
																				</div>
																				
																			</div>
																		</div>
																	</div>
																</div>
																
																<div class="timeline-entry timeline-add">
																	<div class="timeline-stat">
																		<div class="timeline-icon">
																			<i class="fa fa-plus-square-o icon-2x"></i>
																		</div>
																		<!-- <div class="timeline-time">基本信息</div> -->
																	</div>
																	<div class="timeline-label">
																		<button class="btn btn-block"><i class="fa fa-plus"></i> 阶段</button>
																	</div>
																</div>
															</div>
															
															<div  id="three" class="timeline-wrap ui-state-default">
																<div class="timeline-entry timeline-build">
																	<div class="timeline-stat">
																		<div class="timeline-icon">
																			<i class="fa fa-file-code-o icon-2x"></i>
																		</div>
																	</div>
																	<div class="timeline-label">
																		<div class="panel">
																			<div class="panel-heading timeline-sort-drag">
																				<div class="panel-control">
																					<a class="btn btn-link btn-lg" >
																                        <i class="fa fa-pencil"></i> 
																                    </a>
																					<a class="btn btn-link btn-lg" >
																                        <i class="fa fa-trash"></i> 
																                    </a>
																				</div>
																				<h3 class="panel-title stage-name">Build</h3>
																			</div>
																			<div class="panel-body plan-item-list connectedSortable">
																				<div class="plan-item-wrap">
																					<a class="plan-item-add plan-wrap-add">
																						<i class="cds-icon-add"></i> 
																						<span>任务</span>
																					</a>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
																
																<div class="timeline-entry timeline-add">
																	<div class="timeline-stat">
																		<div class="timeline-icon">
																			<i class="fa fa-plus-square-o icon-2x"></i>
																		</div>
																	</div>
																	<div class="timeline-label">
																		<button class="btn btn-block"><i class="fa fa-plus"></i> 阶段</button>
																	</div>
																</div>
															</div>
															
															<div id="four" class="timeline-wrap ui-state-default">
																<div class="timeline-entry timeline-deploy">
																	<div class="timeline-stat">
																		<div class="timeline-icon">
																			<i class="fa fa-file-code-o icon-2x"></i>
																		</div>
																	</div>
																	<div class="timeline-label">
																		<div class="panel">
																			<div class="panel-heading timeline-sort-drag">
																				<div class="panel-control">
																					<a class="btn btn-link btn-lg" >
																                        <i class="fa fa-pencil"></i> 
																                    </a>
																					<a class="btn btn-link btn-lg" >
																                        <i class="fa fa-trash"></i> 
																                    </a>
																				</div>
																				<h3 class="panel-title stage-name">Deploy</h3>
																			</div>
																			<div class="panel-body plan-item-list connectedSortable">
																				<div class="plan-item-wrap">
																					<a class="plan-item-add plan-wrap-add">
																						<i class="cds-icon-add"></i> 
																						<span>任务</span>
																					</a>
																				</div>
																			</div>
																		</div>
																	</div>
																</div>
																
																<div class="timeline-entry timeline-add">
																	<div class="timeline-stat">
																		<div class="timeline-icon">
																			<i class="fa fa-plus-square-o icon-2x"></i>
																		</div>
																	</div>
																	<div class="timeline-label">
																		<button class="btn btn-block"><i class="fa fa-plus"></i> 阶段</button>
																	</div>
																</div>
															
															</div>
														</div>
													</div>
												</div>
<!-- 								<div class="col-lg-2 col-xs-2"> -->
<!-- 										<div id="scrollspy-control"> -->
<!-- 											<nav class="affix"> -->
<!-- 												<ul class="nav"> -->
<!-- 													<li class=""><a href="#one">基本信息</a></li> -->
<!-- 													<li class=""><a href="#two">Source</a></li> -->
<!-- 													<li class=""><a href="#three">Build</a></li> -->
<!-- 													<li class=""><a href="#four">Deploy</a></li> -->
<!-- 												</ul> -->
<!-- 											</nav> -->
<!-- 										</div> -->
<!-- 								</div> -->
											
											</div>
											<div class="panel-footer assemble_line">
													<div class = "row">
														<div class = "col-sm-2 col-sm-offset-7 text-center">
															<a class="btn btn-success btn-block btn-save"> 保存</a>
														</div>
														<div class = "col-sm-2 text-center">
															<a class="btn btn-default btn-block">取消</a>
														</div>	
														
													</div>
											</div>
									</div>
							
							</div>
<!-- 							<div style="height: 70px;"></div> -->
							<div class="col-md-4" style="height:600px;width:33%;">
									<div class="panel panel-default">
											<div class="panel-heading">
												<h3 class="panel-title">
													Pipeline脚本
												</h3>
											</div>
											<div class="panel-body"  style="height:575px;padding:0; ">
											<textarea rows="34" cols="62" id="pipeline"  style="border:0px solid #e5e5e5;resize: none;">
											
											</textarea>

											
											
											</div>
											<div class="panel-footer pipeline_code">
												<div class = "row">
														<div class = "col-sm-3 col-sm-offset-6 text-center">
															<a class="btn btn-success btn-block btn-save"> 保存</a>
														</div>
														<div class = "col-sm-3 text-center">
															<a class="btn btn-default btn-block">取消</a>
														</div>	
														
													</div>
												
											</div>
									</div>
							</div>
					</div>
			</div>


	
<div id="baseInfo_layer_wrapper" class="layer_wrapper" style="display:none;">
	<div class="form-group">
		<label class="control-label"><font color=red>*</font>流水线名称:</label>
		<input id="line-name" type="text" class="form-control" placeholder="请输入流水线名称" />
	</div>
	<div class="form-group">
		<label class="control-label">备注:</label>
		<textarea id="line-desc" class="form-control" rows="3"></textarea>
	</div>
</div>

<div id="stage_layer_wrapper" class="layer_wrapper" style="display:none;">
	<div class="form-group">
		<label class="control-label"><font color=red>*</font>阶段名称：</label>
		<input id="stage-name" type="text" class="form-control" placeholder="请输入阶段名称" />
	</div>
</div>

<div id="job_layer_wrapper" class="layer_wrapper"  style="display:none;">
	<form id="jobForm">
		<div class="form-group">
			<label class="control-label">任务名称：</label>
			<input name="jobName" type="text" class="form-control" placeholder="请输入串行任务名称" />
		</div>
		
	</form>
</div>
			</div>
		</div>

		<!--=========================  过程可视化消息栏  ==========================-->
		<jsp:include page="../framework/aside.jsp" />

		<!--=========================  左侧菜单  ==========================-->
		<jsp:include page="../framework/lefter.jsp" />

	</div>

	<!--=========================  页面底部版权信息  ==========================-->
	<jsp:include page="../framework/footer.jsp" />

	<!--=========================  返回顶层按钮  ==========================-->
	<button class="scroll-top btn">
		<i class="pci-chevron chevron-up"></i>
	</button>
	<!--=========================  选择皮肤功能  ==========================-->
	<jsp:include page="../framework/page-set.jsp" />

	<div id="floating-top-right" class="floating-container"></div>
</div>
<!--===================================================-->
<!-- END OF CONTAINER -->

<jsp:include page="../framework/script.jsp" />
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/common/jquery-ui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/demo/assemblyLine.js"></script>
<script type="text/javascript">


var globalData = "";

	//新建/编辑 流水线 
// 		var _timeline_setting,pipelineId = '',act = '';
var _timeline_setting,pipelineId = '20595a0584e14fefbf267570e5a6c23b',act = 'edit';
$(function(){
//debugger
	if( act=='edit' && pipelineId){
		//编辑
		$('#two,#three,#four').remove();
		$('#scrollspy-control ul.nav>li:not(:first-child)').remove();
		AssemblyLine.reviewCodeInfo();
		AssemblyLine.reviewPipeLineInfo(pipelineId);
	}
	
	$('body').scrollspy({
		target : '#scrollspy-control'
	});
	
	//阶段拖动排序
	$( ".timeline" ).sortable({
		items: ".timeline-wrap",
		handle:".timeline-sort-drag",
		opacity: 0.7,
		distance: 15,//鼠标移动一定距离才响应
		placeholder: "ui-state-highlight",//当拖拽一个 sortable 条目到一个新的位置时，其他条目将为该条目腾出空间。
// 		beforeStop:function(){
// 			AssemblyLine.resetSort();
// 		}
	});
	
	$('input[type="checkbox"].only-checked').change(function() {
		/*  packageType = '02';  */
		//更新后的状态为选中，不处理
		if (!this.checked) {
			//强制选中一个，不可取消
			this.checked = true;
			return false;
		}
		var name = this.name;
		// 删除其它同name的选中状态
		$('input[type="checkbox"][name="' + name + '"]').prop('checked', false);
		//设置当前为选中
		$(this).prop('checked', true);
	});
	//基本信息编辑
	$(document).on('click','.timeline-header .panel-control a',function(){
		//console.info($(this).index());
		var _self = this;
		
		AssemblyLine.baseInfoLayer();
		
		/* var idx = $(_self).index();
		if(idx === 0 ){
			//编辑
			AssemblyLine.baseInfoLayer();
			return true;
		} */
	});
	
	//====================================================================================
	//====================================  阶段   ==========================================
	//====================================================================================
	$(document).on('click','.timeline-entry .panel-control a:not(.plan-item .panel-control a)',function(){
		//console.info($(this).index());
		var _self = this;
		var idx = $(_self).index();
		if(idx === 0 ){

			var $parObj = $(this).parents('.timeline-wrap');
			//console.info($parObj.index());
			//编辑
			AssemblyLine.stageLayer(null,function(){
				$('#stage-name').val($parObj.find('.stage-name').text());
			},function(sname){
				
				$parObj.find('.stage-name').text(sname);
				$('#scrollspy-control ul li:eq('+($parObj.index()-1)+')').find('a').text(sname);
			});
			return true;
		}
		if(idx === 1 ){
			//删除
			layer.confirm('<b>您确定要删除当前设置的阶段？</b><br>操作不可恢复！', {
				icon: 0, 
				title:'温馨提示'
			}, function(index){
				var $entryObj = $(_self).parents('.timeline-wrap');
				var enId = $entryObj[0].id;
				$entryObj.slideUp(400,function(){
					$entryObj.remove();
				});

				var $scr_obj = $('#scrollspy-control ul').find('a[href="#'+enId+'"]').parent('li');
				$scr_obj.slideUp(400,function(){
					$scr_obj.remove();
				});
				
				layer.close(index);
			});
			return true;
		}
	});
	//添加
	$(document).on('click','.timeline-add .btn',function(){
		var $parObj = $(this).parents('.timeline-wrap').length ? $(this).parents('.timeline-wrap') : $(this).parents('.timeline-add');
		//var $nexObj = $parObj.next();
		/* var title = "Source";
		if($nexObj.hasClass('timeline-source')){
			
		}
		
		if($nexObj.hasClass('timeline-build')){
			title = "Build";
		}
		
		if($nexObj.hasClass('timeline-deploy')){
			title = "Deploy";
		} */
		
		var newObj = $('<div class="timeline-wrap ui-state-default" style="display:none;">'+
				'<div class="timeline-entry timeline-build">'+
					'<div class="timeline-stat">'+
					'<div class="timeline-icon">'+
						'<i class="fa fa-file-code-o icon-2x"></i>'+
					'</div>'+
				'</div>'+
				'<div class="timeline-label">'+
					'<div class="panel">'+
						'<div class="panel-heading  timeline-sort-drag">'+
							'<div class="panel-control">'+
								'<a class="btn btn-link btn-lg" >'+
						        	'<i class="fa fa-pencil"></i> '+
						        '</a>'+
								'<a class="btn btn-link btn-lg" >'+
						            '<i class="fa fa-trash"></i>'+
						        '</a>'+
						    '</div>'+
							'<h3 class="panel-title stage-name"></h3>'+
						'</div>'+
						'<div class="panel-body plan-item-list connectedSortable">'+
							'<div class="plan-item-wrap">'+
								'<a class="plan-item-add plan-wrap-add">'+
									'<i class="cds-icon-add"></i> '+
									'<span>任务</span>'+
								'</a>'+
							'</div>'+
						'</div>'+
					'</div>'+
				'</div>'+
			'</div>'+
			'<div class="timeline-entry timeline-add">'+
				'<div class="timeline-stat">'+
					'<div class="timeline-icon">'+
						'<i class="fa fa-plus-square-o icon-2x"></i>'+
					'</div>'+
				'</div>'+
				'<div class="timeline-label">'+
					'<button class="btn btn-block"><i class="fa fa-plus"></i> 阶段</button>'+
				'</div>'+
			'</div></div>');
		
		AssemblyLine.stageLayer(newObj,function(){
				//var newItem = 
			$parObj.after(newObj);
			newObj.slideDown(200);
		},function(sname){
			var objIndex = $('.timeline').find(newObj).index() - 1;
			var lid = 'stage-'+$('.timeline .timeline-wrap').length;
			newObj.attr('id',lid);
			//console.info($('.timeline').find(newObj).index());
			newObj.find('.stage-name').text(sname);
			newObj.find( ".panel>.panel-body" ).sortable({
				items: ".plan-item",
				handle:".panel-heading",
				connectWith: ".plan-item-wrap",
				distance: 15,//鼠标移动一定距离才响应
				placeholder: "ui-state-highlight-item"
			});

			$('#scrollspy-control ul li:eq('+(objIndex-1)+')').after('<li class=""><a href="#'+lid+'">'+sname+'</a></li>');
		});
	});

	//====================================================================================
	//====================================  任务  ==========================================
	//====================================================================================
	//编辑删除
	$(document).on('click','.plan-item .panel-control a',function(){
		//console.info($(this).index());
		var _self = this;
		var idx = $(_self).index();
// 		console.log("idx:"+idx);
		if(idx === 0 ){
			var newObj = $(_self).parents('.plan-item');
// 			console.info("newObj:"+JSON.stringify(newObj.data('jobData')));
			//编辑
			AssemblyLine.jobLayer('edit',newObj,function(){
				AssemblyLine.jobConfigureReview(newObj.data('jobData'));
			},function(jobData){
				
				newObj.data("jobData",jobData);
				
				newObj.find('.panel-title').text("["+jobData.jobType+"] "+jobData.jobName);
				newObj.find('.panel-body').html(jobData.codeSources+" : "+jobData.sourceUrl);
			});
			return true;
		}
		if(idx === 1 ){
			//删除
			layer.confirm('<b>您确定要删除当前设置的任务？</b><br>操作不可恢复！', {
				icon: 0, 
				title:'温馨提示'
			}, function(index){
				var $entryObj = $(_self).parents('.plan-item');
				
				
				AssemblyLine.jobRemove($entryObj);
				
				layer.close(index);
			});
			return true;
		}
	});
	//添加任务
	$(document).on('click','.plan-item-add',function(){
		//var $parObj = $(this).parent('.panel-body');
		//var $nexObj = $parObj.next();
		var _self = this;
		var _parobj = $(_self).parent('.plan-item-wrap');
		var newObj = $('<div class="panel plan-item col-lg-2" >'+
				'<div class="panel-heading">'+
				'<div class="panel-control">'+
					'<a class="btn btn-link" >'+
	                	'<i class="fa fa-pencil"></i> '+
	                '</a>'+
					'<a class="btn btn-link" >'+
	                     '<i class="fa fa-trash"></i> '+
	                '</a>'+
				'</div>'+
				'<h3 class="panel-title"></h3>'+
			'</div>'+
			'<div class="panel-body">'+
			//	'Git: [master] http://127.0.0.1/huawei/layerout.html'+
			'</div>'+
		'</div>'); 
	
// 		console.info("newObj+++:"+JSON.stringify(newObj.data()));
		AssemblyLine.jobLayer('add',newObj,function(){
			if($(_self).hasClass('plan-wrap-add')){
				//非并行任务
				var afterObj = $('<div class="plan-item-wrap row">\n' +
	            '    <a class="plan-item-add">\n' +
	            '      <i class="cds-icon-add"></i>\n' +
	            '      <span>任务</span>\n' +
	            '    </a>\n' +
	            '  </div>\n' +
	            '  <div class="plan-item-wrap">\n' +
	            '    <a class="plan-item-add plan-wrap-add">\n' +
	            '      <i class="cds-icon-add"></i>\n' +
	            '      <span>任务</span>\n' +
	            '    </a>\n' +
	            '  </div>');
				//增加整行区域
				_parobj.after(afterObj);
				//创建新任务元素
				afterObj.find('.plan-item-add:not(.plan-wrap-add)').before(newObj);
			}else{
				$(_self).before(newObj);
			}
			newObj.fadeIn(200);
		},function(jobData){
			newObj.data("jobData",jobData);
// 			console.info("newObj----:"+JSON.stringify(newObj.data('jobData')));
			var jobtype = "";
			switch(jobData.jobType)
			{
				case 'codesources':
					jobtype = jobData.codeSources;
				  	break;
				case 'build':
					jobtype = jobData.buildSystem;
				  	break;
				case 'deploy':
					jobtype = jobData.deploySystem;
					break;
				case 'test':
					jobtype = jobData.testSystem;
					break;
			}
			newObj.find('.panel-title').text(jobData.jobName);
// 			newObj.find('.panel-body').html(jobtype);//+" : "+jobData.sourceUrl
		});
		
		$( ".timeline" ).sortable({
			items: ".timeline-wrap",
			handle:".timeline-sort-drag",
			opacity: 0.7,
			distance: 15,//鼠标移动一定距离才响应
			placeholder: "ui-state-highlight",//当拖拽一个 sortable 条目到一个新的位置时，其他条目将为该条目腾出空间。
			beforeStop:function(){
				AssemblyLine.resetSort();
			}
		});
	});
	//保存
	$('.assemble_line  .btn-save').click(function(){
		//AssemblyLine.getAllData()
		pipelineId = '20595a0584e14fefbf267570e5a6c23b';
			var alldata = AssemblyLine.getAllData();
// 		var alldata = {"sysId":"001","pipelineName":"0002","pipelineDesc":"流水线2","stageList":[{"stageName":"11","jobList":[{"jobName":"11011","jobType":"1","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":1},{"jobName":"11012","jobType":"1","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":1},{"jobName":"11021","jobType":"2","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":3},{"jobName":"11022","jobType":"2","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":3}]},{"stageName":"22","jobList":[{"jobName":"22011","jobType":"3","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":1},{"jobName":"22012","jobType":"3","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":1},{"jobName":"22021","jobType":"4","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":3},{"jobName":"22022","jobType":"4","codeSources":"gitlab","codeGitConfigure":"git配置1","codeGitProjectName":"","codeGitBranch":"","codeSvnConfigure":"svn配置1","buildSystem":"jenkins","buildAssemblingJobType":"jobtype1","buildAssemblingJobName":"job1","JenkinsConfigure":"1","jenkinsView":"1","deploySystem":"cfe","deployCFEPodType":"1","deployCFEAppName":"","deployCFERelease":"","testSystem":"jenkins","testJenkinsConfigure":"1","testJenkinsView":"1","parallelIndex":3}]}]}
		//console.info(alldata);
// 		console.info("alldata: "+JSON.stringify(alldata));
// 		if(!alldata) {
// 			layer.alert('参数错误!');
// 			return false;
// 		}
		$.ajax({
			type : "post",
			url : "${pageContext.request.contextPath}/home/insertPipeline.do",
			data : {"alldata":JSON.stringify(alldata)},
//          data : JSON.stringify(alldata),
//				dataType : 'json',
//          contentType : 'application/json;charset=utf-8',
			success:function(res){
// 				console.log(res);
				if(res == true){
					AssemblyLine.reviewCodeInfo(1);
// 					setTimeout(AssemblyLine.reviewPipeLineInfo(pipelineId,"",1),5000)
					AssemblyLine.reviewPipeLineInfo(pipelineId,"",1);
					
					layer.alert('操作成功 !');
				}else{
					layer.alert('操作失败 !');
				}
			},
			error:function(res){
				layer.alert('新增流水线失败！');
			}
		})
	});
	
	//保存code
	$('.pipeline_code .btn-save').click(function(){
		pipelineId = '20595a0584e14fefbf267570e5a6c23b';
		var pipelineNode = $('#pipeline').val();
// 		console.log("pipelineNode====: "+pipelineNode);
		
		var res = AssemblyLine.pipelineNodeInfo(pipelineNode);
		
// 		console.log("dataList====: " + JSON.stringify(dataList));
		
// 		 [{"stageName":"11","jobNameList":["11011=11012","11021=11022"]},
// 	{"stageName":"22","jobNameList":["22011=22012","22021=22022"]}]
		
		
		
		
		
// 		console.log("res:"+JSON.stringify(res));
		
		
// 		var res = {"pipelineId":"20595a0584e14fefbf267570e5a6c23b","pipelineName":"0002","pipelineDesc":"流水线2","stageList":[
// 						{"stageId":"stageId001","stageName":"11","jobList":[
// 							{"jobName":"11011","parallelIndex":1},
// 							{"jobName":"11012","parallelIndex":1},
// 							{"jobName":"11021","parallelIndex":3},
// 							{"jobName":"11022","parallelIndex":3}]},
// 						{"stageId":"stageId011","stageName":"22","jobList":[
// 							{"jobName":"22011","parallelIndex":1},
// 							{"jobName":"22012","parallelIndex":1},
// 							{"jobName":"22021","parallelIndex":3},
// 							{"jobName":"22022","parallelIndex":3}]
// 						}]
// 		};
					

		
		
		
		$.ajax({
			type : "post",
			url : "${pageContext.request.contextPath}/home/insertPipelineCode.do",
			data : {"pipelineNode":pipelineNode},
//          data : JSON.stringify(alldata),
//				dataType : 'json',
//          contentType : 'application/json;charset=utf-8',
			success:function(result){
				if(result == true){
// 					AssemblyLine.reviewCodeInfo();
					$('.pipeline .timeline-wrap').remove();
					AssemblyLine.reviewStaticInfo(res);
					layer.alert('操作成功 !');
				}else{
					layer.alert('操作失败 !');
				}
			},
			error:function(res){
				layer.alert('新增流水线失败！');
			}
		})
	});
})









</script>
</body>
</html>